package com.gzr.demo01.threadestate;

//守护线程
public class TestDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);
        //开启守护线程
        thread.setDaemon(true);
        thread.start();

        new Thread(you).start();
    }
}

//上帝
class God implements Runnable{
    @Override
    public void run() {
        while (true) {
            System.out.println("上帝守护着你");
        }
    }
}

//你

class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("你开心的活着");
        }
        System.out.println("boodbye! word");
    }
}
